home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / menubutn / form1.frm < prev    next >
Text File  |  1997-07-09  |  3KB  |  104 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Menus With Radio Buttons"
  4.    ClientHeight    =   2715
  5.    ClientLeft      =   165
  6.    ClientTop       =   735
  7.    ClientWidth     =   5190
  8.    Icon            =   "Form1.frx":0000
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   2715
  11.    ScaleWidth      =   5190
  12.    StartUpPosition =   3  'Windows Default
  13.    Begin VB.Label Label1 
  14.       AutoSize        =   -1  'True
  15.       Caption         =   "⌐ 1997 VB Center"
  16.       Height          =   195
  17.       Left            =   120
  18.       TabIndex        =   1
  19.       Top             =   2040
  20.       Width           =   1305
  21.    End
  22.    Begin VB.Label Label2 
  23.       AutoSize        =   -1  'True
  24.       Caption         =   "VB Center Home: http://www.geocities.com/SiliconValley/Way/6445"
  25.       Height          =   195
  26.       Left            =   120
  27.       TabIndex        =   0
  28.       Top             =   2400
  29.       Width           =   4920
  30.    End
  31.    Begin VB.Menu Options 
  32.       Caption         =   "Options"
  33.       Begin VB.Menu mnuOptions 
  34.          Caption         =   "Option Radio Item 1"
  35.          Index           =   0
  36.       End
  37.       Begin VB.Menu mnuOptions 
  38.          Caption         =   "Option Radio Item 2"
  39.          Index           =   1
  40.       End
  41.       Begin VB.Menu mnuOptions 
  42.          Caption         =   "Option Radio Item 3"
  43.          Index           =   2
  44.       End
  45.       Begin VB.Menu mnuOptions 
  46.          Caption         =   "-"
  47.          Index           =   3
  48.       End
  49.       Begin VB.Menu mnuOptions 
  50.          Caption         =   "Option Check Item 1"
  51.          Index           =   4
  52.       End
  53.       Begin VB.Menu mnuOptions 
  54.          Caption         =   "Option Check Item 2"
  55.          Index           =   5
  56.       End
  57.       Begin VB.Menu mnuOptions 
  58.          Caption         =   "Option Check Item 3"
  59.          Index           =   6
  60.       End
  61.    End
  62. End
  63. Attribute VB_Name = "Form1"
  64. Attribute VB_GlobalNameSpace = False
  65. Attribute VB_Creatable = False
  66. Attribute VB_PredeclaredId = True
  67. Attribute VB_Exposed = False
  68. Private Sub Form_Load()
  69.  
  70. ' just change the radio check for the first 3 menu items
  71. SetRadioMenuChecks mnuOptions(0), 0
  72. SetRadioMenuChecks mnuOptions(1), 1
  73. SetRadioMenuChecks mnuOptions(2), 2
  74.  
  75. End Sub
  76. Private Sub SetRadioMenuChecks(Mnu As Menu, ByVal mnuItem&)
  77.  
  78. Dim hMenu&
  79. Dim mInfo As MENUITEMINFO
  80.  
  81. ' get the menu item handle
  82. hMenu& = GetSubMenu(GetMenu(Mnu.Parent.hwnd), 0)
  83.  
  84. ' copy it's attributes to the new Type,
  85. ' changing the checkmark to a radio button
  86. mInfo.cbSize = Len(mInfo)
  87. mInfo.fType = MFT_RADIOCHECK
  88. mInfo.fMask = MIIM_TYPE
  89. mInfo.dwTypeData = Mnu.Caption & Chr$(0)
  90.  
  91. ' change the menu checkmark
  92. SetMenuItemInfo hMenu&, mnuItem&, 1, mInfo
  93.  
  94. End Sub
  95. Private Sub mnuOptions_Click(Index As Integer)
  96.  
  97. Static prevSelection As Integer
  98.  
  99. mnuOptions(prevSelection).Checked = False
  100. mnuOptions(Index).Checked = True
  101. prevSelection = Index
  102.  
  103. End Sub
  104.